package com.ruoyi.common.core.mapper.user;

import com.ruoyi.common.core.domain.user.Employee;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * 相印员工技能Mapper接口
 */
public interface EmployeeSkillMapper {
    /**
     * 查询相印员工所掌握的多项技能
     *
     * @param id 员工ID
     * @return 技能列表，如果没有技能返回空列表
     */
    Employee getSkillsByEmployeeId(String id);

    /**
     * 获取员工列表（支持多条件查询）
     */
    @Select("<script>" +
            "SELECT DISTINCT e.* FROM employee e" +
            "<where>" +
            "   <if test='name != null and name != \"\"'> AND e.name LIKE CONCAT('%', #{name}, '%') </if>" +
            "   <if test='serviceArea != null and serviceArea != \"\"'> AND e.service_area LIKE CONCAT('%', #{serviceArea}, '%') </if>" +
            "   <if test='avgRating != null'> AND ROUND(e.avg_rating,1) = ROUND(#{avgRating},1) </if>" +
            "   <if test='age != null'> AND e.age = #{age} </if>" +
            "   <if test='gender != null'> AND e.gender = #{gender} </if>" +
            "   <if test='phone != null and phone != \"\"'> AND e.phone LIKE CONCAT('%', #{phone}, '%') </if>" +
            "   <if test='experience != null'> AND e.experience = #{experience} </if>" +
            "   <if test='employmentStatus != null'> AND e.employment_status = #{employmentStatus} </if>" +
            "</where>" +
            "</script>")
    List<Employee> getList(@Param("name") String name,
                           @Param("serviceArea") String serviceArea,
                           @Param("avgRating") BigDecimal avgRating,
                           @Param("age") Long age,
                           @Param("gender") Long gender,
                           @Param("phone") String phone,
                           @Param("experience") Long experience,
                           @Param("employmentStatus") Long employmentStatus);

    List<Employee> getListBySkills(@Param("ids") String[] ids,
                                   @Param("name") String name,
                                   @Param("serviceArea") String serviceArea,
                                   @Param("avgRating") BigDecimal avgRating,
                                   @Param("age") Long age,
                                   @Param("gender") Long gender,
                                   @Param("phone") String phone,
                                   @Param("experience") Long experience,
                                   @Param("employmentStatus") Long employmentStatus);
}
